proc lzssStatPack, .buffer, .buffer_size
        begin
        ; pack the data and count the time of the process
        invoke  GetTickCount
        mov     edi,eax
        stdcall lzssPackData, [.buffer],[.buffer_size]
        mov     ebx,eax
        invoke  GetTickCount
        sub     eax,edi
        xor     edx,edx

        mov     esi,1000
        div     esi
        mov     [lzss_stat.time],eax
        mov     esi,eax
        mov     eax,[.buffer_size]
        xor     edx,edx
        or      esi,esi
        jz      @f
        div     esi
    @@:
        shr     eax,10          ; divide eax by 1024
        mov     [lzss_stat.kbytes_per_sec],eax

        xor     eax,eax
        mov     [lzss_stat.total_items],eax
        mov     [lzss_stat.direct_bytes],eax
        mov     [lzss_stat.dictionary_entries],eax

        ; calculate ratio
        mov     edi,[.buffer_size]
        mov     [lzss_stat.size],edi
        mov     eax,[ebx+LZSSData.packed_size]
        mov     [lzss_stat.packed_size],eax
        mov     esi,100
        mul     esi
        div     edi
        mov     [lzss_stat.ratio],eax
        mov     edi,[ebx+LZSSData.unpacked_size]
        ; now scan compressed data
        stdcall BitsCreateFrom, [ebx+LZSSData.data]
        mov     esi,eax
   .unpack:
        inc     [lzss_stat.total_items]
        stdcall BitsGet,esi,1
        or      eax,eax
        jnz     .from_dictionary
        inc     [lzss_stat.direct_bytes]
        stdcall BitsGet,esi,8
        dec     edi
        jz      .finish
        jmp     .unpack
    .from_dictionary:
        stdcall BitsGet, esi,LZSS_OFFSET_BITS         ; load position
        inc     [lzss_stat.dictionary_entries]
        stdcall BitsGet, esi,LZSS_COUNT_BITS          ; load counter
        sub     edi,eax
        sub     edi,LZSS_THRESHOLD+1
        jz      .finish
        js      .finish
        jmp     .unpack
     .finish:
        stdcall BitsDestroy, esi

        mov     eax,ebx
        return
endp

uglobal
  lzss_stat:
    .time               dd ?
    .kbytes_per_sec     dd ?
    .size               dd ?
    .packed_size        dd ?
    .ratio              dd ?

    .total_items        dd ?
    .direct_bytes       dd ?
    .dictionary_entries dd ?
endg